import React, { useState } from "react";
import style from "./style.module.css";
import { Button, Select } from 'antd';
import { withRouter } from "react-router-dom"
import { getPintuanData } from '@/api/request.js'
const { Option } = Select;
function NavCom(props) {

    const handleClick = () => {
        console.log(666);

        props.history.push('/main/pinadd')
        // window.location.href('/main/pinadd')
    }

    let [val, setVal] = useState('')
    let [stateval, setstateval] = useState('-1')
    const changeVal = (e) => {
        setVal(e.target.value)
    }
    function handleChange(value) {
        console.log(`selected ${value}`);
        setstateval(value);
    }
    let clickBtn = async () => {
        let res = await getPintuanData({ input: val, state: stateval })
        let { clickaddbth } = props;
        clickaddbth(res.data.data)
    }
    return (
        <div className={style.headerInput}>
            <span className={style.sousuohuang}>
                状态选择：
                <Select defaultValue={stateval} style={{ width: 120 }} onChange={handleChange}>
                    <Option value="-1">全部</Option>
                    <Option value="1">已开启</Option>
                    <Option value="0">已关闭</Option>
                </Select>
            </span>
            <span className={style.sousuohuang}>
                商品搜索：
                <input type="text" placeholder="请输入商品名称，关键字，商品ID" value={val} onChange={changeVal} className={style.inputSou} />
            </span>
            <Button type="primary" size='large' onClick={clickBtn}>
                搜索
            </Button>
            <Button type="primary" size='large' onClick={props.clickaddbth} onClick={handleClick}>
                添加
            </Button>
        </div>
    );
}

export default withRouter(NavCom);
